// Copyright (c) 2012-2013, yuno. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
//    this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of contributors
//    may be used to endorse or promote products derived from this software
//    without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
package sugarmintcandy.widgetwindow;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public final class PreferenceKeys {
    private PreferenceKeys() {
    }

    public static final String VERSION = "version";
    public static final String SHOW_NOTIFICATION = "show_notification";
    public static final String SHOW_TITLE_BAR_ICON = "show_title_bar_icon";
    public static final String SHOW_HIDE_TITLE_BAR_BUTTON = "show_hide_title_bar_button";
    public static final String SHOW_BRING_TO_FRONT_BUTTON = "show_bring_to_front_button";
    public static final String SHOW_ICONIFY_BUTTON = "show_iconify_button";
    public static final String SHOW_CLOSE_BUTTON = "show_close_button";
    public static final String ANIMATE_ICONIFICATION = "animate_iconification";
    public static final String CURRENT_WORKSPACE = "current_workspace";
    public static final String DONATION_STATE = "donation_state";
    public static final String DEFAULT_COLOR_RANDOM = "default_color_random";
    public static final String DEFAULT_TITLE_BAR_COLOR = "default_title_bar_color";
    public static final String DEFAULT_WINDOW_COLOR = "default_window_color";
    public static final String TITLE_BAR_SIZE = "title_bar_size";
    public static final String ANCHOR = "anchor";

    public static void initDefaultValues(Context context) {
	SharedPreferences prefs = PreferenceManager
		.getDefaultSharedPreferences(context);
	SharedPreferences.Editor editor = prefs.edit();
	int version = prefs.getInt(VERSION, 0);
	if (version < 1) {
	    editor.putBoolean(SHOW_NOTIFICATION, true);
	    editor.putBoolean(SHOW_ICONIFY_BUTTON, true);
	    editor.putBoolean(SHOW_CLOSE_BUTTON, true);
	    editor.putBoolean(ANIMATE_ICONIFICATION, true);
	    editor.putInt(CURRENT_WORKSPACE, 1);
	    editor.putInt(DONATION_STATE, BillingService.STATE_UNPARCHASED);
	}
	if (version < 2) {
	    editor.putBoolean(DEFAULT_COLOR_RANDOM, true);
	    editor.putInt(DEFAULT_TITLE_BAR_COLOR, 0xffc0c0c0);
	    editor.putInt(DEFAULT_WINDOW_COLOR, 0x80c0c0c0);
	}
	if (version < 3) {
	    editor.putBoolean(SHOW_TITLE_BAR_ICON, true);
	}
	if (version < 4) {
	    editor.putString(TITLE_BAR_SIZE, "24");
	}
	if (version < 5) {
	    editor.putString(ANCHOR, Anchor.NONE.name());
	}
	if (version < 6) {
	    editor.putBoolean(SHOW_HIDE_TITLE_BAR_BUTTON, false);
	    editor.putBoolean(SHOW_BRING_TO_FRONT_BUTTON, false);
	    editor.putInt(VERSION, 6);
	    editor.commit();
	}
    }
}
